<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>今天吃什么？</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        .container {
            text-align: center;
        }
        .wheel {
            width: 300px;
            height: 300px;
            border-radius: 50%;
            position: relative;
            overflow: hidden;
            border: 10px solid #333;
            transition: transform 5s cubic-bezier(0.25, 0.1, 0.25, 1);
        }
        .wheel-item {
            position: absolute;
            width: 50%;
            height: 50%;
            transform-origin: 100% 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: bold;
            color: white;
        }
        .spin-button {
            margin-top: 20px;
            padding: 10px 20px;
            font-size: 18px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .spin-button:hover {
            background-color: #45a049;
        }
        .result {
            margin-top: 20px;
            font-size: 24px;
            font-weight: bold;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>今天吃什么？</h1>
    <div class="wheel" id="wheel"></div>
    <button class="spin-button" id="spinButton">抽签</button>
    <div class="result" id="result"></div>
</div>

<script>
    const wheel = document.getElementById('wheel');
    const spinButton = document.getElementById('spinButton');
    const result = document.getElementById('result');

    const foods = ['黄焖鸡', '火锅面', '肯德基', '盖浇饭', '小炒菜'];
    const colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A', '#98D8C8'];

    // 创建轮盘
    foods.forEach((food, index) => {
        const item = document.createElement('div');
        item.className = 'wheel-item';
        item.style.transform = `rotate(${index * (360 / foods.length)}deg)`;
        item.style.backgroundColor = colors[index];
        item.innerHTML = food;
        wheel.appendChild(item);
    });

    function spin() {
    spinButton.disabled = true;
    const rotation = 3600 + Math.floor(Math.random() * 360);
    wheel.style.transform = `rotate(${rotation}deg)`;

    setTimeout(() => {
        const actualRotation = rotation % 360;
        const itemAngle = 360 / foods.length;
        const selectedIndex = Math.floor((360 - actualRotation) / itemAngle);
        const selectedFood = foods[selectedIndex];
        result.textContent = `今天吃：${selectedFood}！`;
        spinButton.disabled = false;
        linkObj.messageFromHtml(selectedFood);
    }, 5000);

    function openDialog() {
      // 返回抽奖结果
      linkObj.messageFromHtml(selectedFood);
    }

}

spinButton.addEventListener('click', spin);
</script>
</body>
</html>


